<?php
include_once "mdbtable.php";

class MReferer extends MDbTable {

	public $table = "referer";

	public function getIdByEmail($desyatnik_id, $email)
	{
		$referer_id = 0;
		$arr = array('desyatnik_id' => $desyatnik_id, 'email' => trim($email));
		$referers = $this->getList($arr);
		if(count($referers))
		{
			$referer = reset($referers);
			$referer_id = $referer['id'];
		}
		else
		{
			$this->save($arr, $referer_id);
		}
		return $referer_id;
	}


}

